package com.kanshu.ksgb.fastread.doudou.app.test;

public class ReaderItem {

    String bookId;
    int order;
    int itemPos;
    String content;
    boolean isChapterName = false;

    static int adTextNum = 1000;
    static int currentTextNumBottom = 0;
    static int currentTextNumTop = 0;
    boolean addTop = false;
    boolean showAd;

    public ReaderItem(String bookId, int order, int itemPos, String content) {
        this(bookId, order, itemPos, content, false);
    }

    public ReaderItem(String bookId, int order, int itemPos, String content, boolean addTop) {
        this.bookId = bookId;
        this.order = order;
        this.itemPos = itemPos;
        this.content = content;
        this.addTop = addTop;
        //累加字数，判断是否加载广告
        isShowAd();
    }

    private void isShowAd() {
        if (addTop) {
            currentTextNumTop += content.length();
            if (currentTextNumTop > adTextNum) {
                showAd = true;
                currentTextNumTop = 0;
            } else {
                showAd = false;
            }
        } else {
            currentTextNumBottom += content.length();
            if (currentTextNumBottom > adTextNum) {
                showAd = true;
                currentTextNumBottom = 0;
            } else {
                showAd = false;
            }
        }
    }

    public static void init() {
        currentTextNumBottom = 0;
        currentTextNumTop = 0;
    }

    public ReaderItem() {
    }
}
